package servlet;

import bean.Log;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/getLogs")
public class LogsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        LogsServiceImpl service = new LogsServiceImpl();
        String seat_name = req.getParameter("seat_name");
        String person_id = req.getParameter("person_id");
        String time = req.getParameter("time1");
        String s_or_f =  req.getParameter("s_or_f");


        List<Log> logList = service.getLogs(seat_name);
        req.setAttribute("seat_name",seat_name);
        req.setAttribute("person_id",person_id);
        req.setAttribute("time",time);
        req.setAttribute("logList",logList);
        req.setAttribute("s_or_f",s_or_f);
        req.getRequestDispatcher("Appointment.jsp").forward(req,resp);
    }
}
